package com.weixin.engine.design.chain;

/**
 * 对请求数据进行签名的处理程序
 *
 * @author wangchunhui
 * @date 2023/7/20 10:05
 */
public class RequestSigningHandler implements Handler {
    private Handler nextHandler;

    @Override
    public void setNext(Handler handler) {
        this.nextHandler = handler;
    }

    @Override
    public void handleRequest(Request request) {
        signRequest(request);
        if (nextHandler != null) {
            nextHandler.handleRequest(request);
        }
    }

    @Override
    public void handleResponse(Response response) {

    }

    private void signRequest(Request request) {
        // 在此处进行签名逻辑
        request.setSignature("generated_signature");
    }
}